package com.example.demo.juc.lock;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Description:
 * @Author: xiatian
 * @CreateTime: 2021/8/23
 * @Company: kangxu
 */
public class TestLock {
    public void test() throws InterruptedException {
        final Lock lock = new ReentrantLock();
        lock.lock();
        Thread t1 =new Thread(new Runnable() {

            @Override
            public void run() {
                lock.lock();
                System.out.println(Thread.currentThread().getName()+"interruptl.");
            }
        },"child thread -1");
        t1.start();
        Thread.sleep(1000);
        t1.interrupt();
        Thread.sleep(1000000);
    }

    public static void main(String[] args) throws InterruptedException {
        new TestLock().test();
    }
}
